package com.hykc.auth.common.advice;

import com.aopuxun.common.exceptions.DdException;
import com.aopuxun.common.vo.ExceptionResult;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

@ControllerAdvice
public class BaseExceptionAdvice {
    @ExceptionHandler(DdException.class)
    public ResponseEntity<ExceptionResult> exceptionHandler(DdException e){
        return ResponseEntity.status(e.getStatus()).body(new ExceptionResult(e));
    }
    @ExceptionHandler(RuntimeException.class)
    public ResponseEntity<String> handleRuntimeException(RuntimeException e) {
        return ResponseEntity.status(500).body(e.getMessage());
    }
}
